package Task8;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            while (scanner.hasNext()){
                int n = scanner.nextInt();
                String[] strings = new String[n];
                for (int i = 0; i < n; i++) {
                    strings[i] = scanner.next();
                }
                if(isDicsort(strings)&&isLengthsort(strings)){
                    System.out.println("both");
                } else if (isDicsort(strings)) {
                    System.out.println("lexicographically");
                }else if(isLengthsort(strings)){
                    System.out.println("lengths");
                }else {
                    System.out.println("none");
                }
            }
    }
    public static boolean isDicsort(String[] strings){
        for (int i = 0; i < strings.length - 1; i++) {
            if(strings[i].compareTo(strings[i+1]) > 0){
                return false;
            }
        }
        return true;
    }
    public static boolean isLengthsort(String[] strings){
        for (int i = 0; i < strings.length - 1; i++) {
            if(strings[i].length() > strings[i+1].length()){
                return false;
            }
        }
        return true;
    }
}
